out = $out; $this->depth = 0; } /** * visit a file and process it * * @param vfsStreamFile $file * @return vfsStreamPrintVisitor */ public function visitFile(vfsStreamFile $file) { $this->printContent($file->getName()); return $this; } /** * visit a block device and process it * * @param vfsStreamBlock $block * @return vfsStreamPrintVisitor */ public function visitBlockDevice(vfsStreamBlock $block) { $name = '[' . $block->getName() . ']'; $this->printContent($name); return $this; } /** * visit a directory and process it * * @param vfsStreamDirectory $dir * @return vfsStreamPrintVisitor */ public function visitDirectory(vfsStreamDirectory $dir) { $this->printContent($dir->getName()); $this->depth++; foreach ($dir as $child) { $this->visit($child); } $this->depth--; return $this; } /** * helper method to print the content * * @param string $name */ protected function printContent($name) { fwrite($this->out, str_repeat(' ', $this->depth) . '- ' . $name . "\n"); } }